General

Components

Community

Development

TDF

Documents > Cookbook >Cell Range



Get CellRange
You can get cell range by providing start and end index of the column and row,or just provide start and end address of the cell(if you are using the spreadsheet.)

	    CellRange cellRange = table.getCellRangeByPosition(1, 0, 2, 0);
CellRange cellRangeAdd = table.getCellRangeByPosition("$E1","$E6");


Merge Text Table
The code below merges all of the selected cells into one:

	    Table table1 = document.getTableByName("Table1");
CellRange cellrange = table1.getCellRangeByPosition(0, 0, table1.getColumnCount()-1, table1.getRowCount()-1);
cellRange.merge();


Merge Text Column
The code below shows how to merge the cells of the first column into one :

	    	table1 = document.getTableByName("Table1");
CellRange firstColumn = table1.getCellRangeByPosition(0, 0, 0, table1.getRowCount()-1);
firstColumn.merge();


Merge Text Row
The code below shows how to merge the cells of the first 2 rows into one :

		table1 = document.getTableByName("Table1");
int rowCount = table1.getRowCount();
CellRange firstTwoRow = table1.getCellRangeByPosition(0, 0, table1.getColumnCount()-1, 1);
firstTwoRow.merge();


Merge SpreadSheet
Merge a spreadsheet's cell is the same as text document.Especially,when getting the cell range of spreadsheet,you can use special address instead of index.

		Table sheet1 = document.getTableByName("Sheet1");
CellRange cellRange2 = sheet1.getCellRangeByPosition("$E1","$E6");
cellRange2.setCellRangeName("TimeCellRange");
cellRange2.merge();


Impressum (Legal Info) | Privacy Policy (Datenschutzerklärung) | Statutes (non-binding English translation) - Satzung (binding German version) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Apache License, v2.0. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License v2.0. “LibreOffice” and “The Document Foundation” are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy. LibreOffice was based on OpenOffice.org.